package atividadesSegundoPlano;

import java.io.IOException;

public class ColetorInformacoes {
	
	private static final String REFERENCIA_HOST = "Nome do host:                                 "; 
	
	public static String getSystemInfo(){
		
		StringBuilder       sb     = new StringBuilder();
		Process processo;
		try {
			processo = Runtime.getRuntime().exec("systeminfo");
			if(processo != null){  
		        
				java.io.InputStream is = processo.getInputStream();
		        
		        byte[] b = new byte[8];  
		        
		        try{  
		            while((is.read(b)) != -1){  
		                sb.append(new String(b, "ASCII"));  
		            }  
		        }  
		        catch(java.io.IOException ex){  
		        	ex.printStackTrace();  
		        }  
		    }  
		    
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		return new String(sb); 
	}
	
	public static String getNomeHost(String systemInfo){
		
		int posicaoInicio = systemInfo.indexOf(REFERENCIA_HOST);
		posicaoInicio = posicaoInicio + REFERENCIA_HOST.length();
		
		int posicaoFim = systemInfo.indexOf("\n",posicaoInicio);
		
		return systemInfo.substring(posicaoInicio, posicaoFim);
	}
	
	public static String getCapacidadeMemRAM(){
		return "";
	}

	public static String getcapacidadeHD(){
		return "";
	}
	
	public static String getSistemaOperacional(){
		return "";
	}
	
}
